package com.malamute.core.tag;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.components.Component;
import org.apache.struts2.views.jsp.ComponentTagSupport;

import com.opensymphony.xwork2.util.ValueStack;

/**
 * @Title:PageTag.java
 * @Package com.malamute.core.tag
 * @Description 分页标签 解析类
 * @author AceGuan gjybst@163.com
 * @date 2012-1-31 下午09:49:42
 * @version v1.0 see：http://tangshuo.iteye.com/blog/189447
 * 
 */
public class PageTag extends ComponentTagSupport {
	private String cpage;// 当前页
	private String tpage;// 总页面
	private String url;// 请求地址

	/**
	 * 设置cpage
	 * 
	 * @param cpage
	 */
	public void setCpage(String cpage) {
		this.cpage = cpage;
	}

	/**
	 * 设置tpage
	 * 
	 * @param tpage
	 */
	public void setTpage(String tpage) {
		this.tpage = tpage;
	}

	/**
	 * 设置url
	 * 
	 * @param url
	 */
	public void setUrl(String url) {
		this.url = url;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @param stack
	 * 
	 * @param req
	 * 
	 * @param res
	 * 
	 * @return
	 * 
	 * @see
	 * org.apache.struts2.views.jsp.ComponentTagSupport#getBean(com.opensymphony
	 * .xwork2.util.ValueStack, javax.servlet.http.HttpServletRequest,
	 * javax.servlet.http.HttpServletResponse)
	 */
	@Override
	public Component getBean(ValueStack stack, HttpServletRequest req,
			HttpServletResponse res) {
		return new Pages(stack);// 返回Pages Component，分页的逻辑处理都在这个Component中
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.apache.struts2.views.jsp.ComponentTagSupport#populateParams()
	 */
	@Override
	protected void populateParams() {
		super.populateParams();
		Pages pages = (Pages) component;
		pages.setCpage(cpage);
		pages.setTpage(tpage);
		pages.setUrl(url);
	}

}
